package org.example.JUC.waitTest.asynchronous;

import java.util.concurrent.Callable;

/**
 * @description:
 * @author: farprt
 * @create: 2022-08-21 01:28
 **/
public class App {

    public static void main(String[] args) {
        MyExecutor executor=new MyExecutor();
        Callable<Integer> subTask=new Callable<Integer>() {
            @Override
            public Integer call() throws Exception {
                //执行异步任务
                int millis=(int)(Math.random()*1000);
                Thread.sleep(millis);
                return millis;
            }
        };
        MyFuture<Integer> future=executor.execute(subTask);
        //执行其他操作
        try {
            Integer result = future.get();
            System.out.println(result);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}